﻿namespace FietsenManagementJB
{
    using System;
    using System.ComponentModel;

    [Serializable]
    class Bike : INotifyPropertyChanged
    {
        private int id;
        private string type;
        private string gender;
        private DateTime buyDate;
        private decimal buyPrice;    
        private DateTime sellDate;
        private decimal sellPrice;
        private string locationBought;
        private decimal investmentPrice;
        private string bikePictureImgLoc;
        private int frame;
        private string frameNr;
        private decimal balance;
        private bool sold;

        public Bike(int id, string type, string gender, DateTime buyDate, decimal buyPrice,
            decimal sellPrice, string locationBought, decimal investmentPrice, DateTime sellDate, string bikePictureImgLoc
            , int frame, string framenr, decimal balance, bool sold)
        {
            this.id = id;
            this.type = type;
            this.gender = gender;
            this.buyPrice = buyPrice;
            this.sellPrice = sellPrice;
            this.locationBought = locationBought;
            this.investmentPrice = investmentPrice;
            this.buyDate = buyDate;
            this.sellDate = sellDate;
            this.bikePictureImgLoc = bikePictureImgLoc;
            this.frame = frame;
            this.frameNr = framenr;
            this.balance = balance;
            this.sold = sold;
        }

        public Bike()
        {
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string name)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(name));
        }

        #region Accessors
        // Accessors
        [DisplayName("Naam / Type")]
        public string Type
        {
            get { return type; }
            set { type = value; }
        }

        [DisplayName("Winst / Verlies")]
        public decimal Balance
        {
            get { return balance; }
            set { balance = value; }
        }

        [Browsable(false)]
        public string BikePicture
        {
            get { return bikePictureImgLoc; }
            set { bikePictureImgLoc = value; }
        }

        [DisplayName("Inkoop datum")]
        public DateTime BuyDate
        {
            get { return buyDate; }
            set { buyDate = value; }
        }

        [DisplayName("Verkoop datum")]
        public DateTime? SellDate
        {
            get { return sellDate; }
            set { sellDate = value.Value; }
        }

        [DisplayName("Geslacht")]
        public string Gender
        {
            get { return gender; }
            set { gender = value; }
        }

        [DisplayName("Investering")]
        public decimal InvestmentPrice
        {
            get { return Math.Round(investmentPrice,2); }
            set { investmentPrice = value; }
        }

        [DisplayName("Inkoop locatie")]
        public string LocationBought
        {
            get { return locationBought; }
            set { locationBought = value; }
        }

        [DisplayName("Inkoop prijs")]
        public decimal BuyPrice
        {
            get { return Math.Round(buyPrice,2); }
            set { buyPrice = value; }
        }

        [DisplayName("Verkoop prijs")]
        public decimal SellPrice
        {
            get { return Math.Round(sellPrice,2); }
            set { sellPrice = value; }
        }

        [DisplayName("Frame hoogte")]
        public int Frame
        {
            get { return frame; }
            set { frame = value; }
        }

        [DisplayName("Frame nummer")]
        public string FrameNr
        {
            get { return frameNr; }
            set { frameNr = value; }
        }

        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        [Browsable(false)]
        public bool Sold
        {
            get { return sold; }
            set { sold = value; }
        }

        #endregion
    }
}
